package com.example.demo.web;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import java.io.FileNotFoundException;

@Slf4j
@RestController
public class WebController {


    @PostMapping("/test")
    public String test(@RequestBody String param){
        System.out.println(param);
        JSONArray jArray=JSON.parseArray(param);
        System.out.println(jArray);
        return "success";
    }

    @GetMapping("/getVideo")
    public JSONObject getVideo() throws FileNotFoundException {
        log.info("hello");
        String name = ResourceUtils.getFile("testVideo1.mp4").getName();
        JSONObject obj1 = new JSONObject();
        JSONObject obj2 = new JSONObject();
        obj2.put("value","https://www.mlqtsgwhg.com/test/16976870630206659425a-ad9e-4179-9a3d-745891922820.mp4" );
        obj1.put("data",obj2);
        return obj1;
    }


    @GetMapping("/getVideo2")
    public ModelAndView getVideo2() throws FileNotFoundException {
        JSONObject obj1 = new JSONObject();
        JSONObject obj2 = new JSONObject();
        obj2.put("value","https://vd3.bdstatic.com/mda-ph0bhe5bg872dsfi/sc/h264/1690877255518885134/mda-ph0bhe5bg872dsfi.mp4" );
        obj1.put("data",obj2);
        return new ModelAndView().addAllObjects(obj1);
    }
}
